<?php

use App\Http\Controllers\ActivityController;
use App\Http\Controllers\AttachmentController;
use App\Http\Controllers\AuthController;
use App\Http\Controllers\CaptchaController;
use App\Http\Controllers\CodeController;
use App\Http\Controllers\CommentController;
use App\Http\Controllers\FavoriteController;
use App\Http\Controllers\LearnHistoryController;
use App\Http\Controllers\LessonController;
use App\Http\Controllers\SignController;
use App\Http\Controllers\SystemController;
use App\Http\Controllers\TopicController;
use App\Http\Controllers\UserController;
use App\Http\Controllers\VideoController;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::post('send/code', [CodeController::class, 'send']);

Route::controller(AuthController::class)->prefix('auth')->group(function () {
    Route::post('login', 'login');
    Route::post('logout', 'logout');
    Route::post('register', 'register');
    Route::post('password', 'password');
});

Route::get('user/info', [UserController::class, 'info']);
Route::post('user/mobile', [UserController::class, 'mobile']);
Route::apiResource('user', UserController::class);

Route::controller(TopicController::class)->prefix('topic')->group(function () {
    Route::apiResource('', TopicController::class)->parameters(['' => 'topic']);
});
//系统课程
Route::post('system/order', [SystemController::class, 'order']);
Route::apiResource('system', SystemController::class);
//课程
Route::apiResource('lesson', LessonController::class);
//视频
Route::apiResource('video', VideoController::class);
//签到
Route::apiResource('sign', SignController::class);
//收藏
Route::post('favorite/{type}/{id}', [FavoriteController::class, 'toggle']);

//评论
Route::post('comment/{type}/{id}', [CommentController::class, 'store']);
Route::get('comment/{type}/{id}', [CommentController::class, 'index']);
Route::apiResource('comment', CommentController::class);

//图形验证码
Route::get('captcha', CaptchaController::class);

//上传
Route::post('upload/image', [AttachmentController::class, 'image']);

//动态
Route::apiResource('activity', ActivityController::class);

//学习动态
Route::get('learnHistory/{user}', [LearnHistoryController::class, 'getByUser' ]);
Route::apiResource('learnHistory', LearnHistoryController::class);
